# -*- coding: utf-8 -*-
import wmi
class applys():
    def __init__(self, nic_id=1):
        '''
        初始化一个网卡实例
        :param nic_id:输入一个网卡ID(1是第一个，所以实际值需要： ID + 1 )
        '''
        self.nic_id = int(nic_id)
        self.wmiService = wmi.WMI()
        self.colNicConfigs = self.wmiService.Win32_NetworkAdapterConfiguration(IPEnabled=True)
        # self.nic = self.colNicConfigs[self.nic_id]
    def get_info(self,id):
        '''
        通过
        :param id:指定一个网卡ID
        :return:
        '''
        list = {'ID: ': id}
        list.update({'NAME: ': self.colNicConfigs[id].Description})
        list.update({'IPV4: ': self.colNicConfigs[id].IPAddress[0]})
        list.update({'IPV6: ': self.colNicConfigs[id].IPAddress[1]})
        list.update({'DNS1 IP:': self.colNicConfigs[id].DNSServerSearchOrder[0]})
        list.update({'DNS2 IP:': self.colNicConfigs[id].DNSServerSearchOrder[1]})
        list.update({'MASK:': self.colNicConfigs[id].IPSubnet[0]})
        if self.colNicConfigs[id].DefaultIPGateway:
            list.update({'默认网关: ': self.colNicConfigs[id].DefaultIPGateway[0]})
        return list
up = applys()
for i in up.get_info(0):
    print(i, up.get_info(id=0)[i])